package com.xyzwps.server.paimon.app.dto

import com.xyzwps.server.paimon.Dicts
import com.xyzwps.server.paimon.ext.validOrThrow
import io.konform.validation.Validation
import io.konform.validation.constraints.maximum
import io.konform.validation.constraints.minimum
import org.springframework.web.bind.annotation.RequestParam

data class ArticlesGetInput(
    @RequestParam(required = false)
    val cursor: String?,
    @RequestParam(required = false, defaultValue = Dicts.PAGE_SIZE_DEFAULT_TEXT)
    val count: Int
) : ValidInput {
    companion object {
        val validator = Validation {
            ArticlesGetInput::count {
                minimum(Dicts.PAGE_SIZE_MIN)
                maximum(Dicts.PAGE_SIZE_MAX)
            }
        }
    }

    override fun validateOrThrow() = validator.validOrThrow(this)
}